//
//  MDNavigationController.m
//  jewelryMD
//
//  Created by chuifeng on 2018/4/24.
//  Copyright © 2018年 洪闽程. All rights reserved.
//
// 字体
#define KFONTSIZE(f) [UIFont fontWithName:@"Helvetica" size:(f)*KWIDTHSCALE]
//加粗字体
#define KFONTBOLDSIZE(f) [UIFont fontWithName:@"Helvetica-Bold" size:(f)*KWIDTHSCALE]
#define KFONTHEAVYSIZE(f) [UIFont fontWithName:@"Helvetica-Heavy" size:(f)*KWIDTHSCALE]

#import "MDNavigationController.h"
#import "GQGesVCTransition.h"
#import "UIBarButtonItem+MDBarButtonItem.h"

@interface MDNavigationController ()

@end

@implementation MDNavigationController

#pragma mark - load初始化一次

- (void)viewDidLoad {
    [super viewDidLoad];
    [GQGesVCTransition validateGesBackWithType:GQGesVCTransitionTypePanWithPercentRight withRequestFailToLoopScrollView:YES]; //手势返回
    
    //自定义导航栏用mynavigationBar
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backButtonTapClick) name:@"popNotification" object:nil];
    
    [self setUpBase];
}

#pragma mark - 初始化
- (void)setUpBase
{
    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg.png"] forBarMetrics:UIBarMetricsDefault];;
    
    NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
    // 设置导航栏字体颜色
    UIColor * naiColor = [UIColor whiteColor];
    attributes[NSForegroundColorAttributeName] = naiColor;
    attributes[NSFontAttributeName] =[UIFont systemFontOfSize:15];
    self.navigationBar.titleTextAttributes = attributes;
    //返回按钮箭头
    UIImage *backimage =[[UIImage imageNamed:@"返回1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self.navigationBar setBackIndicatorTransitionMaskImage:backimage];
    [self.navigationBar setBackIndicatorImage:backimage];
    //返回按钮字颜色
    [self.navigationBar setTintColor:[UIColor clearColor]];
    // 就有滑动返回功能
    self.interactivePopGestureRecognizer.delegate = nil;
}

#pragma mark push
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.childViewControllers.count > 0)
    {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

- (void)backButtonTapClick
{
    [self popViewControllerAnimated:YES];
}

@end
